package com.itheima.ex;

import com.itheima.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class MyEx {

    @ExceptionHandler(Exception.class)
    public Result myex(Exception e){
        //获取前端控制器的错误信息
        String message = e.getMessage();
        if (message.equals("Access is denied")){
            return new  Result(false,"无权限访问");
        }
        return new Result(false,"未知错误");
    }
}
